import type { GoodsDetail, GoodsItem, OrderData, OrderRecordItem } from '@/types/mall'
import { MallModel } from '../models/mall'
import type {
  APICreateTaobaoGift,
  APICreateTaobaoGiftReqData,
  APIGetGoodsDetailReqData,
  APIGetGoodsReqData,
  APIGetOrderReqData,
  APIGetRecordReqData,
  APIGoodsDetail,
} from '@/types/api/mall'

export class MallService {
  protected mallModel: MallModel
  constructor() {
    this.mallModel = new MallModel()
  }
  // 获取商品列表
  async getGoodsList(params: APIGetGoodsReqData): Promise<GoodsItem[]> {
    return await this.mallModel.getGoodsList(params)
  }
  // 获取商品详情
  async getGoodsDetail(params: APIGetGoodsDetailReqData): Promise<GoodsDetail> {
    return await this.mallModel.getGoodsDetail(params)
  }
  // 获取订单列表
  async getOrderList(params: APIGetOrderReqData): Promise<OrderData> {
    return await this.mallModel.getOrderList(params)
  }
  // 获取购物金记录列表
  async getRecordList(params: APIGetRecordReqData): Promise<OrderRecordItem[]> {
    return await this.mallModel.getRecordList(params)
  }
  // 创建淘礼金
  async createTaobaoGift(params: APICreateTaobaoGiftReqData): Promise<APICreateTaobaoGift> {
    return await this.mallModel.createTaobaoGift(params)
  }
}
